<#include "../header.ftl" />
<@head title="修改文章" />
		<script type="text/javascript" src="${base}/script/kindeditor/kindeditor.js" charset="utf-8"></script>
		<script type="text/javascript" src="${base}/script/mlog.editor.js" charset="utf-8"></script>
		<script type="text/javascript" src="${base}/script/mlog.form.js" charset="utf-8"></script>
		<script type="text/javascript" src="${base}/script/jquery-validation/jquery.validate.js"></script>
		<script type="text/javascript" src="${base}/script/jquery-validation/jquery.metadata.js"></script>
		<script type="text/javascript" src="${base}/script/jquery-validation/validate.method.js"></script>
		<script type="text/javascript" src="${base}/script/jquery.form.js" charset="utf-8"></script>
		<script type="text/javascript">
			$(document).ready(function(){
				mlog.editor.init({
					model : "all",
					id : "content"
				});
				mlog.editor.init({
					model : "simple",
					id : "summary"
				});
				
				mlog.form.validate({
					selector : "#postForm",
					errorLabelContainer : "#error",
					wrapper: 'li',
					onfocusout : false,
					onkeyup : false,
					onclick : false
				});
			});
			
			
			function displayToggle(){
				var id = $('#id').val();
				if(id){
					$('#attach_frame').attr('src', '${base}/common/attachment/uploadview?fkey=' + id + '&ftype=POST');
					$('#attachment').fadeToggle();
				}
			}
			function addAttachFile(path,name){
				if (mlog.editor.map['content'].designMode === false){
					alert('请先切换到所见所得模式');
				} else {
					mlog.editor.map['content'].insertHtml('<span class=\"attachment\"><a target=\"_blank\" href=\"'+path+'\" >'+name+'</a></span>');
				}
			}
			
			function addAttachImage(path,id){
				if (mlog.editor.map['content'].designMode === false){
					alert('请先切换到所见所得模式');
				}else if (path != "") {
					mlog.editor.map['content'].insertHtml('<a target=\"_blank\" href=\"'+path+'\" id=\"ematt:'+id+'\"><img src=\"'+path+'\" title="点击查看原图" border=\"0\" /></a>');
				}
			}
		</script>
		<@side.sidenav active="文章管理"/>
	    <div class="g-content">
	        <div class="g-content-container">
	            <div class="g-p">
					<div class="m-crumb">
					    <ul class="f-cb">
					        <li><i>&gt;</i><a href="${spaceUrl}/admin">博客管理</a></li>
					        <li><i>&gt;</i><a href="${spaceUrl}/admin/post/list">文章管理</a></li>
					        <li><i>&gt;</i><a href="javascript:void(0);">修改文章</a></li>
					    </ul>
					</div>
					<div class="page-title">
						<h1>修改文章</h1>
					</div>
					<div class="m-content">
						<div id="error" class="message error" style="display:none;"></div>
						<@spring.bind "post" />
						<form name="postForm" id="postForm" action="${spaceUrl}/admin/post/edit/do" method="POST">
							<@spring.formHiddenInput path="post.status" />
							<@spring.formHiddenInput path="post.id" />
							<@spring.formHiddenInput path="post.author.id" />
							<@spring.formHiddenInput path="post.createTime" />
							<@spring.formHiddenInput path="post.comments" />
							<@spring.formHiddenInput path="post.postIp" />
							<@spring.formHiddenInput path="post.views" />
							<div class="label">
								<span class="title">标题：</span>
								<@spring.formInput path="post.title" attributes='validate=\'{required:true,maxlength:30, messages:{required:"请输入文章标题", maxlength:"文章标题字数不能超过{0}"}}\' size="3" placeholder="请输入文章标题" class="input" style="width:50%;"' />
								<span class="title">分类：</span>
								<@spring.formSingleSelect path="post.catalog.id" options=catalogs has_default=true attributes='validate=\'{required:true, messages:{required:"请选择文章分类"}}\' class="input"'/>
							</div>
							<div class="label" id="attachment" style="display: none;">
								<iframe id="attach_frame" width="98%" height="230" frameborder="0"></iframe>
							</div>
							<div class="label">
								<span class="title">正文：(必填)&nbsp;&nbsp;<a href="javascript:displayToggle();" style="font-weight: bold; color:red;">插入图片</a></span>
								<div class="ipt">
									<@spring.formTextarea path="post.content" attributes='style="height:200px;width:98%;"' />
								</div>
							</div>
							<div class="label">
								<span class="title">摘要：(选填)</span>
								<div class="ipt">
									<@spring.formTextarea path="post.summary" attributes='style="height:150px;width:98%;"' />
								</div>
							</div>
							<div class="label">
								<span class="title">来源链接：</span>
								<@spring.formInput path="post.sourceUrl" attributes='validate=\'{maxlength:200, messages:{maxlength:"来源链接不能超过{0}字符"}}\' placeholder="请输入文章转载链接" class="input" style="width:50%;"' />
							</div>
							<div class="label">
								<span class="title">来源站点：</span>
								<@spring.formInput path="post.sourceSite" attributes='validate=\'{maxlength:100, messages:{maxlength:"来源站点不能超过{0}字符"}}\' placeholder="请输入文章转载站点" class="input" style="width:50%;"' />
							</div>
							<div class="label">
								<span class="title">访问密码：</span>
								<@spring.formInput path="post.password" attributes='validate=\'{maxlength:18, messages:{maxlength:"访问不能超过{0}字符"}}\' placeholder="请输入文章访问密码" class="input" style="width:50%;"' />
							</div>
							<div class="label">
								<span class="title">是否置顶：</span>
								<@spring.formRadioButtons path="post.isTop" options=isTop defaultValue="false" separator="&nbsp;" />
							</div>
							<div class="label">
								<span class="title">评论设置：</span>
								<@spring.formRadioButtons path="post.commentStatus" options=commentStatus defaultValue="open" separator="&nbsp;" />
							</div>
							<div class="label">
								<a href="javascript:void(0);" onclick="post(this);" class="button"><i class="icon-post"></i>发表文章</a>
							</div>
						</form>
					</div>
	            </div>
	        </div>
	    </div>
	    <script type="text/javascript">
	    	function post(btn){
	    		if($('#postForm').valid()){
	    			changeButtomLoading(btn);
    				$('#postForm').submit();
	    		}
	    	}
	    </script>
<#include "../footer.ftl" />